using ShadeTree.Binding.Configuration;
using ShadeTree.Binding.Lists;

namespace ShadeTree.Binding.Elements
{
    public class ListElementExpression : ScreenElementExpression<ListElementExpression>
    {
        private readonly IListElement _element;

        public ListElementExpression(IListElement element) : base(element)
        {
            _element = element;
        }

        protected override ListElementExpression thisExpression()
        {
            return this;
        }

        public ListElementExpression FillWithValues(params string[] array)
        {
            _element.FillWithList(array);
            return this;
        }

        public ListElementExpression FillWith(IPicklist list)
        {
            _element.FillWithList(list);
            return this;
        }

        public ListElementExpression FillWithList(string name)
        {
            IPicklist list = ListRepository.GetList(name);
            return FillWith(list);
        }

        public ListElementExpression FillWithList<T>()
        {
            IPicklist list = ListRepository.GetList<T>();
            return FillWith(list);
        }
    }
}